package jbpmguice.instantiation;

import org.jbpm.instantiation.FieldInstantiator;


/**
 * This Instantiator loads the GuiceFieldInstantiator.GuiceFieldInstantiator configuration and instantiates new objects.
 * <p/>
 * User: goettl
 * Date: 11.02.11
 * Time: 10:30
 */
public class GuiceFieldInstantiator extends FieldInstantiator {
    String configType = "GuiceFieldInstantiator";

    @SuppressWarnings({"rawtypes", "unchecked"})
    public Object newInstance(Class clazz) {
        return GuiceConfigurationLoader.getConfigurationLoader().getInstance(clazz);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        GuiceFieldInstantiator guiceFieldInstantiator = (GuiceFieldInstantiator) o;

        if (!configType.equals(guiceFieldInstantiator.configType)) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return configType.hashCode();
    }
}
